<?php 
	Class stage_projet_seminaire_m extends CI_Model
	{

		public function addStageProjetSeminaire()
	    {	
	    	$id_stage = "GMSPS".rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
	    	if($this->db->select('*')->from('GMStageProjetSeminaire')->where('GMStageProjetSeminaire.GMSPS_CODE', $id_stage)->get())
	    	{
	    		$id_stage = "GMSPS".rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
	    	}
			$data = array(
							'GMSPS_CODE' => $id_stage,
							'GMET_CODE' =>  $this->input->post('GMET_CODE'),
							'GMSPS_TITRE' =>  $this->input->post('GMSPS_FONCTION'),
							'GMSPS_DESCRIPTION' => $this->input->post('GMSPS_EMAIL'),
							'GMSPS_ENTREPRISE' =>  $this->input->post('GMSPS_ENTREPRISE'),
							'GMSPS_RESPONSABLE' => $this->input->post('GMSPS_RESPONSABLE'),
							'GMSPS_DATE_DE_DEBUT' => $this->input->post('GMSPS_DATE_DE_DEBUT'),
							'GMSPS_DATE_DE_FIN' => $this->input->post('GMSPS_DATE_DE_FIN'),
							'GMSPS_NATURE_STAGE' => $this->input->post('GMSPS_NATURE_STAGE'),
							'GMSPS_TYPE' => $this->input->post('GMSPS_TYPE'),
							'GMSPS_PAYS' => $this->input->post('GMSPS_PAYS')
										 
    					);
			$this->db->insert('GMStageProjetSeminaire', $data);
		}

		public function editStageProjetSeminaire()
	    {	
			$data = array(
							'GMSPS_TITRE' =>  $this->input->post('GMSPS_FONCTION'),
							'GMSPS_DESCRIPTION' => $this->input->post('GMSPS_EMAIL'),
							'GMSPS_ENTREPRISE' =>  $this->input->post('GMSPS_ENTREPRISE'),
							'GMSPS_RESPONSABLE' => $this->input->post('GMSPS_RESPONSABLE'),
							'GMSPS_DATE_DE_DEBUT' => $this->input->post('GMSPS_DATE_DE_DEBUT'),
							'GMSPS_DATE_DE_FIN' => $this->input->post('GMSPS_DATE_DE_FIN'),
							'GMSPS_NATURE_STAGE' => $this->input->post('GMSPS_NATURE_STAGE'),
							'GMSPS_TYPE' => $this->input->post('GMSPS_TYPE'),
							'GMSPS_PAYS' => $this->input->post('GMSPS_PAYS')				 
    					);
			$this->db->where('GMSPS_CODE', $this->input->post('GMSPS_CODE'));
			$this->db->update('GMStageProjetSeminaire', $data);
		}

		public function getAllStageProjetSeminaire($val)
		{
			$where = array ('GMStageProjetSeminaire.GMET_CODE' => $val);
			$value = $this->db->select('GMSPS_CODE, GMSPS_TITRE, GMSPS_DESCRIPTION, GMSPS_ENTREPRISE, GMSPS_RESPONSABLE, GMSPS_DATE_DE_DEBUT, GMSPS_DATE_DE_FIN, GMSPS_NATURE_STAGE, GMSPS_TYPE, GMSPS_PAYS')->from('GMStageProjetSeminaire')->where($where)->order_by('GMSPS_DATE_DE_DEBUT','DESC')->get();
			return $value->result();
		}

		public function getStageProjetSeminaire()
		{
			$where = array ('GMStageProjetSeminaire.GMSPS_CODE' => $this->input->post('GMSPS_CODE'));
			$value = $this->db->select('*')->from('GMStageProjetSeminaire')->where($where)->get();
			return $value->row();
		}

		public function deleteStageProjetSeminaire()
	    {	
			$where = array(
							'GMSPS_CODE' => $this->input->post('GMSPS_CODE')	
    					);
			$this->db->delete('GMStageProjetSeminaire', $where);
		}

	}
?>